package cn.bdqn.biz_consumer.service;


import cn.bdqn.common.EmptyUtils;
import cn.bdqn.pojo.Doctor;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
public class SolrServiceImpl implements SolrService {
    @Resource
    private SolrClient solrClient;

    @Override
    public List<Doctor> getDocList(Doctor doctor) throws Exception {
        SolrQuery query = new SolrQuery("*:*");
        List<Doctor> doctors=new ArrayList<>();
        if (EmptyUtils.isEmpty(doctor)) {

            QueryResponse queryResponse = solrClient.query(query);
             doctors=queryResponse.getBeans(Doctor.class);
        }

        return doctors;
    }
}
